<%@page import="com.kaishengit.entity.Prod"%>
<%@page import="com.kaishengit.dao.ProdDao"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.kaishengit.entity.User"%>
<%@ page import="com.kaishengit.dao.UserDao"%>
<%
	String name=request.getParameter("username");
	String pwd=request.getParameter("password");
	System.out.println("name:"+name+"\tpassword:"+pwd);

	UserDao dao = new UserDao();
	User user = dao.findByUserNameAndPassword(name, pwd);
	if(name == null || pwd == null) {
		response.sendRedirect("index.jsp");
		return;
	} 
	if(user != null) {
		session.setAttribute("user",user);
		response.sendRedirect("home.jsp");
		/* ProdDao proddao = new ProdDao();
		List<Prod> prodlist = proddao.findAll();
		
		request.setAttribute("prodlist", prodlist);
		request.setAttribute("myuser", user);
		request.getRequestDispatcher("main.jsp").forward(request,response); */
	} else {
		response.sendRedirect("index.jsp?code=10001");
	}

%>